<template>
	<view class="content">
		<!-- <view class="uni-list yd-cell-box search_date">
			<view class="uni-flex lyx-flex-align-items-center">
				<view class="uni-list-cell-left">
					选择时段
				</view>
				<view class="uni-list-cell-db">
					<picker mode="multiSelector" :range="dateData" @change="bindDateChange" :value="svalue">
						<view class="uni-input">{{date}}</view>
					</picker>
				</view>
			</view>
		</view> -->

		<view class="yd-cell-box" v-if="dataList.length>0">
			<view class="yd-cell">
				<view class="yd-cell-item" v-for="(item,index) in dataList" v-bind:key="index" @click="goToDetail(item.id)">
					<view class="yd-cell-left">{{item.title}}</view>
					<view class="yd-cell-right">{{item.create_time}}</view>
				</view>
			</view>
		</view>

		<view v-if="dataList.length==0" class="uni-flex lyx-flex-direction-column" style="text-align: center;color: #888888;margin-top:120upx;">
			<view style="padding: 10upx;">
				<image style="width: 100upx;height: 100upx;" src="../../static/img/ico_empty.png"></image>
			</view>
			<view style="padding: 10upx;">
				没有数据
			</view>
		</view>

	</view>
</template>
<script>
	import {
		mapState
	} from 'vuex'

	export default {
		data() {
			return {
				title: 'picker',
				index: 0,
				date: '',
				time: '12:01',
				dataList: [],
				dateData: [
					["2019"],
					["01", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
				],
				svalue: [0, 0],
				type: ''
			}
		},
		computed: { ...mapState(['forcedLogin', 'hasLogin', 'userName']),

		},
		onLoad(option) {
			console.log(option.id, '页面传递过来的id');
			this.type = option.id;
			this.getGongZiData(this.date, option.id);

		},
		onPullDownRefresh() {
			this.getGongZiData(this.date, this.type)
		},
		methods: {
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.index = e.target.value
			},
			bindDateChange: function(e) {
				let data = this.dateData;
				this.date = data[0][e.target.value[0]] + '-' + data[1][e.target.value[1]]
				this.getGongZiData(this.date, this.type)
			},
			bindTimeChange: function(e) {
				this.time = e.target.value
			},
			getGongZiData(date, type) {
				uni.showLoading({
					title: '加载中'
				});
				this.$http.getOneMouthList(date, type).then(ret => {
					uni.hideLoading();
					uni.stopPullDownRefresh();
					if (ret.status == 1) {
						let data = ret.result.data;
						if (data.length > 0) {
							this.dataList = data;
						}
						this.date = ret.result.month;
					} else {
						this.dataList = [];
					}
				})
			},
			goToDetail(id) {
				uni.navigateTo({
					url: '../detail/detail?id=' + id
				});
			}
		}
	}
</script>

<style>
	.search_date {
		height: 100upx;
	}
</style>
